<template>
    <div class="form-group">
        <label for="opacity">透明度</label>
        <div class="range-input-group">
            <input type="range" id="opacity" min="0.1" max="1" step="0.01" v-model="opacity"
                @input="handleOpacityChange" class="range-slider">
            <span class="range-value">{{ opacity }}</span>
        </div>
    </div>
</template>

<script setup>
import { ref,inject } from 'vue'
const opacity = inject('opacity');

// Emits
const emit = defineEmits(['opacity-change'])

// 响应式数据
// const opacity = ref(1)

// 方法
function handleOpacityChange() {
    emit('opacity-change', opacity.value)
}

// 暴露数据
// defineExpose({
//     opacity
// })
</script>

<style scoped>
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.range-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.range-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: #e1e1e1;
    border-radius: 3px;
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #1890ff;
    border-radius: 50%;
    cursor: pointer;
}

.range-value {
    min-width: 40px;
    font-size: 14px;
    color: #666;
}
</style>